from typing import *


class Solution:
    def maximumLength(self, s: str) -> int:

        n = len(s)
        for i in range(n - 2, 0, -1):
            cnt = Counter()
            for j in range(n - i + 1):
                if len(Counter(s[j : j + i])) == 1:
                    cnt[s[j : j + i]] += 1
                    if cnt[s[j : j + i]] == 3:
                        print(s[j : j + i])
                        return i
        return -1


s = Solution()
print(s.maximumLength("cccerrrecdcdccedecdcccddeeeddcdcddedccdceeedccecde"))
